import { S } from '../../s';
import { IPSDEAction } from './ipsdeaction';
import { IPSDEActionLogic } from './ipsdeaction-logic';
import { IPSSysPFPlugin } from '../../res/ipssys-pfplugin';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSDEActionImplBase
  extends PSModelObjectImpl
  implements IPSDEAction
{
  get actionHolder(): 1 | 2 | 3 {
    return this.M.actionHolder != null ? this.M.actionHolder : 3;
  }

  get actionMode():
    | 'CREATE'
    | 'READ'
    | 'UPDATE'
    | 'DELETE'
    | 'CUSTOM'
    | 'GETDRAFT'
    | 'UNKNOWN'
    | 'MOVEORDER'
    | 'CHECKKEY'
    | 'USER'
    | 'USER2'
    | 'USER3'
    | 'USER4' {
    return this.M.actionMode;
  }

  get actionTag(): string {
    return this.M.actionTag;
  }

  get actionTag2(): string {
    return this.M.actionTag2;
  }

  get actionTag3(): string {
    return this.M.actionTag3;
  }

  get actionTag4(): string {
    return this.M.actionTag4;
  }

  get actionType():
    | 'USERCUSTOM'
    | 'DELOGIC'
    | 'BUILTIN'
    | 'SELECTBYKEY'
    | 'USERCREATE'
    | 'USERUPDATE'
    | 'USERSYSUPDATE'
    | 'SCRIPT'
    | 'REMOTE' {
    return this.M.actionType;
  }

  protected afterpsdeactionlogics: IPSDEActionLogic[];
  getAfterPSDEActionLogics(): IPSDEActionLogic[] | null {
    return (
      this.afterpsdeactionlogics ||
      (this.afterpsdeactionlogics = this.fillChildListModel(
        this.M.getAfterPSDEActionLogics,
        S._1d2,
      ) as IPSDEActionLogic[])
    );
  }

  get batchActionMode(): 0 | 1 | 2 | 5 | 6 {
    return this.M.batchActionMode != null ? this.M.batchActionMode : 0;
  }

  protected beforepsdeactionlogics: IPSDEActionLogic[];
  getBeforePSDEActionLogics(): IPSDEActionLogic[] | null {
    return (
      this.beforepsdeactionlogics ||
      (this.beforepsdeactionlogics = this.fillChildListModel(
        this.M.getBeforePSDEActionLogics,
        S._1d2,
      ) as IPSDEActionLogic[])
    );
  }

  protected checkpsdeactionlogics: IPSDEActionLogic[];
  getCheckPSDEActionLogics(): IPSDEActionLogic[] | null {
    return (
      this.checkpsdeactionlogics ||
      (this.checkpsdeactionlogics = this.fillChildListModel(
        this.M.getCheckPSDEActionLogics,
        S._1d2,
      ) as IPSDEActionLogic[])
    );
  }

  get codeName(): string {
    return this.M.codeName;
  }

  get extendMode(): 0 | 2 {
    return this.M.extendMode != null ? this.M.extendMode : 0;
  }

  get logicName(): string {
    return this.M.logicName;
  }

  get orderValue(): number {
    return this.M.orderValue != null ? this.M.orderValue : 99999;
  }

  protected pssyspfplugin: IPSSysPFPlugin;
  getPSSysPFPlugin(): IPSSysPFPlugin | null {
    return (
      this.pssyspfplugin ||
      (this.pssyspfplugin = this.fillObjectModel(
        S._27c,
        this.M.getPSSysPFPlugin,
        S._2a7,
      ) as IPSSysPFPlugin)
    );
  }

  get paramMode(): 1 | 2 | 3 {
    return this.M.paramMode != null ? this.M.paramMode : 1;
  }

  protected preparepsdeactionlogics: IPSDEActionLogic[];
  getPreparePSDEActionLogics(): IPSDEActionLogic[] | null {
    return (
      this.preparepsdeactionlogics ||
      (this.preparepsdeactionlogics = this.fillChildListModel(
        this.M.getPreparePSDEActionLogics,
        S._1d2,
      ) as IPSDEActionLogic[])
    );
  }

  get tempDataMode(): 0 | 1 | 2 {
    return this.M.tempDataMode != null ? this.M.tempDataMode : 0;
  }

  get testActionMode(): 0 | 1 | 3 {
    return this.M.testActionMode != null ? this.M.testActionMode : 0;
  }

  get timeOut(): number {
    return this.M.timeOut != null ? this.M.timeOut : -1;
  }

  get asyncAction(): boolean {
    return this.M.asyncAction != null ? this.M.asyncAction : false;
  }

  get batchAction(): boolean {
    return this.M.batchAction != null ? this.M.batchAction : false;
  }

  get builtinAction(): boolean {
    return this.M.builtinAction != null ? this.M.builtinAction : false;
  }

  get customParam(): boolean {
    return this.M.customParam != null ? this.M.customParam : false;
  }

  get enableBackend(): boolean {
    return this.M.enableBackend != null ? this.M.enableBackend : true;
  }

  get enableFront(): boolean {
    return this.M.enableFront != null ? this.M.enableFront : true;
  }

  get enableTempData(): boolean {
    return this.M.enableTempData != null ? this.M.enableTempData : false;
  }

  get valid(): boolean {
    return this.M.valid != null ? this.M.valid : true;
  }
  get cls(): string {
    return 'PSDEActionImplBase';
  }
  instanceof(cls: string): boolean {
    if (cls == S._1f8) return true;
    return super.instanceof(cls);
  }
}
